/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { AppRegistry, Text, View } from 'react-native';
import IntentsPage from './src/bundles/intents/IntentsPage';
import VibratorPage from './src/bundles/vibrator/VibratorPage';
import KnockSharePage from './src/bundles/knockShare/KnockSharePage';
import FeaturesListPage from './src/bundles/featuresList/FeaturesListPage';
import FolderStackPage from './src/bundles/folderStack/FolderStackPage';
import PasteBoardPage from './src/bundles/pasteBoard/PasteBoardPage';
import FoldSplitContainerPage from './src/bundles/folderStack/FoldSplitContainerPage';
import MediaProcessingPage from './src/bundles/mediaProcessing/MediaProcessingPage';
import PickerPage from './src/bundles/picker/PickerPage';
import MovingPhotoPage from './src/bundles/movingPhoto/MovingPhotoPage';
import React from 'react';

// 使用setWrapperComponentProvider来包装根组件。
// children: 渲染RN侧组件；<Text> 鸿蒙侧传递过来的数据内容。
AppRegistry.setWrapperComponentProvider((appParams) => {
    return function ({ children, ...otherProps }) {
    if (
      Object.keys(otherProps.initialProps).includes('styles') &&
      Object.keys(otherProps.initialProps).includes('stringParam')
    ) {
      return (
        <View style={otherProps.initialProps.styles.container}>
          <View
            style={{
              borderRadius: 10,
              backgroundColor: '#FAE6B1',
              height: 100,
              justifyContent: 'center',
              alignItems: 'center',
            }}>
                    <Text style={otherProps.initialProps.styles.apiFontSize}>{otherProps.initialProps.stringParam}</Text>
                </View>
                <View>{children}</View>
        </View>
      );
        } else {
            return children;
        }
    };
});

AppRegistry.registerComponent('IntentsPage', () => IntentsPage);
AppRegistry.registerComponent('FolderStackPage', () => FolderStackPage);
AppRegistry.registerComponent('FoldSplitContainerPage', () => FoldSplitContainerPage);
AppRegistry.registerComponent('VibratorPage', () => VibratorPage);
AppRegistry.registerComponent('KnockSharePage', () => KnockSharePage);
AppRegistry.registerComponent('FeaturesListPage', () => FeaturesListPage);
AppRegistry.registerComponent('MediaProcessingPage', () => MediaProcessingPage);
AppRegistry.registerComponent('PickerPage', () => PickerPage);
AppRegistry.registerComponent('MovingPhotoPage', () => MovingPhotoPage);
AppRegistry.registerComponent('PasteBoardPage', () => PasteBoardPage);